Repository navigation
⚡ Bolt: Wrap-Up comebacks skip titles played in the past year before the max() look-up - #368
Merged
Merged
Conversation
…the max() look-up Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014GBDVACPfnJRWf1X64gcFN
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After #360,
wrapup_facts._comebacksis still the biggest single cost of a Wrap-Up. Its last-earlier-play look-up runsmax(viewed_at) GROUP BY coalesce(series_title, title)over every earlier play of every title seen in the period. A member's regular artists have thousands of earlier plays each, so the query walks most of the history.Measured on a temp DB seeded like a real install (384k music plays over 3 years, 20k film/episode plays, ANALYZE run):
_comebacks, week: 1.42 s median; month: 2.14 s.build_wrapup_facts, week: 2.93 s; month: 4.66 s.Change
A title with any play in the 365 days before the period's latest first-play cannot have a gap of 365+ days. One range scan on the existing
ix_wh_user_type_viewedcollects those titles, and themax()look-up runs only for the rest. Same final query and same output. The cutoff ismax(first play in period) - 365d, so only titles that cannot qualify are dropped.Measured effect / proof
_comebacks: week 1.42 s → 0.22 s; month 2.14 s → 0.21 s.build_wrapup_facts: week 2.93 s → 1.81 s; month 4.66 s → 3.02 s.Tests
tests/test_wrapup_comebacks_index.pyextended: a title played the year before is no comeback; 364 days of silence is no comeback and 366 is; titles played within the year are not passed to themax()look-up.test_enrichment_status_perf.py, which also fails on untouched main in the sandbox (SQLite 3.45.1 plan) and passes in CI.Risk & edge cases
series_titleuse the samecoalescekey in both queries.Duplicate check
Searched the journal, the other personas' journals, open and closed PRs for "comebacks" and "wrapup", and the last 300 commits on main. Only #360 touches this function, and this builds on it.
Generated by Claude Code